<template>
  <view class="container">
    <view class="head">
      <view class="head_bg">
        <image src="/static/my/vipbg.png" mode="widthFix"></image>
      </view>
      <view class="head_main">
        <view class="head_main_title">
          <text>知识区超级会员</text>
          <view @click="gotoAccountDetail">明细记录 <uv-icon name="arrow-right" color="#fff" size="12"></uv-icon>
          </view>
        </view>
        <view class="head_main_footer">
          <image src="/static/my/jihuojiage.png" mode=""></image>
          好课0元学
        </view>
      </view>
    </view>
    <view class="main">
      <view class="main_box" :class="acitveBox == index ? 'main_box_active':''" v-for="(item,index) in list"
        @tap="boxHandler(index)" :key="index">
        <image v-if="acitveBox == index" src="/static/my/check.png" mode=""></image>
        <view class="main_box_head">{{item.dateStr}}</view>
        <view class="main_box_price">
          <text>￥</text>
          <view>{{item.price}}</view>
        </view>
        <text>{{item.des}}</text>
      </view>

    </view>
    <view class="main_footer">
      <view class="main_footer_left">
        <image src="/static/my/fenxiang2.png" mode=""></image>
        分享好友
      </view>
      <button class="main_footer_btn flex-center">立即开通</button>
    </view>
  </view>
</template>

<script setup lang="ts">
  import { ref } from 'vue';
  import { onLoad } from '@dcloudio/uni-app'

  const acitveBox = ref(0)
  const list = ref([])
  const data = [
    {
      dateStr: '7天',
      des: '约12.28元/天',
      price: '128.00'
    }, {
      dateStr: '3个月',
      des: '约12.28元/天',
      price: '1080.00'
    }, {
      dateStr: '12个月',
      des: '约12.28元/天',
      price: '1920.00'
    }
  ]
  const gotoAccountDetail = () => {
    uni.navigateTo({
      url: '/pages/mySecondary/account/detail'
    })
  }
  const boxHandler = (index : number) => {
    acitveBox.value = index
  }
  onLoad(() => {
    list.value.push(...data)
  })
</script>

<style lang="less" scoped>
  .container {
    border-top: 1px solid rgba(#000, .1);

    .head {
      width: 750rpx;

      &_bg {
        width: 750rpx;
        height: 452rpx;
        position: relative;
        position: absolute;
        top: -72rpx;
        left: 0;

        image {
          width: 750rpx;
        }
      }

      &_main {
        height: 350rpx;
        position: relative;
        z-index: 9;
        color: #FFFFFF;
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        padding: 0 30rpx;
        box-sizing: border-box;
        padding-bottom: 30rpx;

        &_title {
          display: flex;
          justify-content: space-between;
          align-items: center;
          font-size: 44rpx;

          view {
            display: flex;
            align-items: center;
            font-size: 24rpx;
          }
        }

        &_footer {
          display: flex;
          flex-direction: column;
          align-items: center;
          width: 160rpx;

          image {
            width: 26rpx;
            height: 26rpx;
            margin-bottom: 12rpx;
          }
        }
      }
    }

    .main {
      position: relative;
      z-index: 10;
      width: 750rpx;
      height: 896rpx;
      margin-top: -40rpx;
      background: #FFFFFF;
      border-radius: 30rpx 30rpx 0rpx 0rpx;
      padding: 54rpx 30rpx 0;
      box-sizing: border-box;
      display: grid;
      grid-template-columns: 33.33% 33.33% 33.33%;

      &_box {
        width: 200rpx;
        height: 233rpx;
        box-shadow: 0rpx 3rpx 10rpx 0rpx rgba(0, 0, 0, 0.1);
        border-radius: 10rpx;
        background: #fff;
        border: 1px solid #999999;
        padding: 30rpx 0;
        box-sizing: border-box;
        margin: 0 auto;
        font-size: 24rpx;
        color: #666666;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: space-between;
        position: relative;

        &_head {
          font-weight: bold;
          font-size: 28rpx;
          color: #333333;
        }

        &_price {
          font-weight: 500;
          color: #228CFE;
          display: flex;
          align-items: flex-end;

          view {
            font-weight: 700;
            font-size: 36rpx;
            margin-bottom: -5rpx;
          }
        }
      }

      &_box_active {
        background: #E5F2FF;
        border: 1px solid #228CFE;

        image {
          width: 40rpx;
          height: 40rpx;
          position: absolute;
          top: -1px;
          right: -1px;
        }
      }

      
    }
    .main_footer {
      position: fixed;
      bottom: 20rpx;
      left: 0;
      z-index: 99;
      display: flex;
      padding: 20rpx 30rpx;
      box-sizing: border-box;
      width: 100%;
      justify-content: space-between;
      align-items: center;
    
      image {
        width: 32rpx;
        height: 32rpx;
        margin-bottom: 5rpx;
      }
    
      &_left {
        font-size: 24rpx;
        color: #666666;
        display: flex;
        flex-direction: column;
        align-items: center;
      }
    
      &_btn {
        width: 580rpx;
        height: 68rpx;
        background: #228CFE;
        box-shadow: 0rpx 3rpx 10rpx 0rpx rgba(0, 0, 0, 0.2);
        border-radius: 34rpx;
        font-weight: 500;
        font-size: 30rpx;
        color: #FFFFFF;
        margin: 0;
      }
    }
  }
</style>